<template>
  <div class="energy" v-cloak>
    <div class="marks" :style="{ height: contentHeight }" @click="shrink"></div>
    <list
        ref="scroller"
        @scroll="onScroll"
        @touchstart="onTouchStart"
        @touchmove="onTouchMove"
        @touchend="onTouchEnd"
        class="list">
        <cell class="listItem" v-for="(item, index) in longList" :key="index" @click="addClassFun(index)" :class="[index === activeIndex ? 'active' : '']">
            <text class="text" :class="[index === activeIndex ? 'active' : '']">{{item}}</text>
        </cell>
      </list>
  </div>
</template>
<script>
import { Utils } from 'weex-ui';
export default {
  name: 'energy',
  data () {
    return {
      longList:['全部', '户/台', '分户/台'],
      activeIndex: 0,
      mainHeight: 0,
      contentHeight: 0
    }
  },
  created () {
    this.mainHeight = Utils.env.getScreenHeight()
    this.contentHeight = this.mainHeight - 206.2
  },
  methods: {
    addClassFun (index) {
      this.activeIndex = index;
    }
  }
}
</script>
<style scoped>
.energy{
  width: 750px;
  flex: 1;
}
.marks{
  width: 750px;
  background-color: rgba(0,0,0,0.4);
  position: relative;
}
.list{
  width: 750px;
  background-color: #fff;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}
.listItem{
  width: 750px;
  height: 100px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-left: 20px; 
  border-bottom-color: #f5f5f5;
  border-bottom-style: solid;
  border-bottom-width: 1px;
}
.text{
  font-size: 29.1px;
  font-family:PingFangSC-Regular;
  color:rgba(102,102,102,1);
}
.active{
  color: #fff;
  background-color: rgba(62,175,252,1);
}
[v-cloak] {
  display: none;
}
</style>